<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
body{margin:0px;overflow-x:hidden;overflow-y:auto;}
.STYLE1{font-size:12px;color:#FFFFFF;}
.STYLE3{font-size:12px;color:#033d61;}
.menu_title SPAN {FONT-WEIGHT: bold; LEFT: 3px; COLOR: #ffffff; POSITION: relative; TOP: 2px}
.menu_title2 SPAN{FONT-WEIGHT: bold; LEFT: 3px; COLOR: #FFCC00; POSITION: relative; TOP: 2px}
.column{cursor:pointer;height:20px;padding-top:2px;font-size:12px;color:#033d61;}
a:link{COLOR:#033d61;text-decoration:none;}
a:visited{COLOR:#033d61;text-decoration:none;}
a:active{COLOR:#033d61;text-decoration:none;}
a:hover{COLOR:#033d61;text-decoration:none;}
-->
</style>
<script language="JavaScript" type="text/JavaScript" src="js/common.js"></script>
<script language="JavaScript" type="text/JavaScript" src="tree/jQuery1.6.2.js"></script>
<link rel="STYLESHEET" type="text/css" href="tree/dhtmlxtree.css">
<script  src="tree/dhtmlxcommon.js"></script>
<script  src="tree/dhtmlxtree.js"></script>
<script type="text/javascript" src="tree/jquery.contextmenu.js"></script>
<script language="JavaScript" type="text/JavaScript" src="js/dialog/dialog.js"></script>
<script type="text/javascript">
function showMsg(id,title,icon,str){
  art.dialog.through({id:'msg',title:title,icon:icon,drag:false,lock:true,content:str,ok:function(){art.dialog.close();}});
}

function tondrag(id, id2){
  alert(id);alert(id2);
    return confirm("Do you want to move node " + tree.getItemText(id) + " to item " + tree.getItemText(id2) + "?");
};

$(document).ready(function(){
  //$(document).bind("contextmenu",function(){return false;});
  //$(document).bind("selectstart",function(){return false;});
  tree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
  tree.setSkin('dhx_skyblue');
  tree.setImagePath("./tree/imgs/");

  //tree.setImageArrays("plus", "open2.gif", "open2.gif", "open2.gif", "open2.gif", "open2.gif");
  //tree.setImageArrays("minus", "close2.gif", "close2.gif", "close2.gif", "close2.gif", "close2.gif");


  //设置节点图片 setStdImages('无子目录时的图片','节点展开后的图片','节点未展开时的图片')
  tree.setStdImages("folderClosed.gif", "folderOpen.gif", "folderClosed.gif");
  tree.enableDragAndDrop(1);
  tree.enableTreeLines(false);
  tree.setOnRightClickHandler(function(id){
    //var i=tree.getSelectedItemId();
    //alert(i);
    tree.selectItem(id);
    $("#mm").val(id);
  });

  tree.setDragHandler(function(id,id2){
    //art.dialog.confirm("Do you want to move node " + tree.getItemText(id) + " to item " + tree.getItemText(id2) + "?",function(){
      $.post("tree/move_folder.php",{id1:id,id2:id2},function(tips){
          //art.dialog.through({title:'信息',icon:'face-smile',lock:true,content:tips,ok:function(){art.dialog.close();location.reload();}});
      });
      return true;
    //});
  });


  //tree.setXMLAutoLoading("./tree/get.php");
  tree.loadXML("./tree/get.php");
setTimeout('a()',100);

});

function a(){

    $('#treeboxbox_tree span').contextMenu('jqueryDtreeMenu',{
    onContextMenu: function(e) {
      if(1){
          return true;
      }else return false;
    },
    bindings: {
      'new':function(t){
        id=$(t).attr("name");
        id=parseInt(id);
        if(id==-1){
          title='创建目录';
        }else{
          title='在“'+$(t).html()+'”目录下 创建';
        }
        art.dialog.open(global_current_folder+'tree/edit_folder.php?do=create&current_folder_id='+id,{id:'edit',title:title,lock:true,height:'60px',resize:false},false);
      },
      'modify':function(t){
        id=$(t).attr("name");
        //“我的文档”中，是以当前用户的“用户名”为根目录的。比如员工的登陆帐号为：郑明，则“我的文档”中，以“郑明”为根目录做为起点。该名称不可更改。增加对$parentId的判断，就是避免给用户造成错觉。
        if(id==-1){
          showMsg(0,'提示','face-smile','该名称不可修改');
          return false;
        }else{
          var name=$(t).html();
          name=encodeURIComponent(encodeURIComponent(name));
          art.dialog.open(global_current_folder+'tree/edit_folder.php?do=modity&name='+name+'&current_folder_id='+id,{id:'edit',title:'修改目录',lock:true,height:'60px',resize:false},false);
        }
      },
      'delete':function(t){
        id=$(t).attr("name");
        if(id==-1){
          showMsg(0,'提示','face-smile','该目录不可删除');
          return false;
        }else{
          var name=$(t).html();
          art.dialog.confirm('确认删除“'+name+'”目录吗？',function(){
           $.post("tree/del_folder.php",{id:id},function(tips){
              art.dialog.through({title:'信息',icon:'face-smile',lock:true,content:tips,ok:function(){art.dialog.close();location.reload();}
              });
            });
            return true;
          });
        }
      },
      'refresh': function(t) {
        location.reload();
      }
    }
  });

}
</script>
<table>
<tr>
  <td valign="top">
  <div id="treeboxbox_tree" style="width:250px;height:218px;background-color:#f5f5f5;border:1px solid Silver;"></div>
  </td>
</tr>
</table>
<input type="text" id="mm" value="">


<style>
  .m{font-size:13px;padding-left:5px;}
</style>
<!-- 右键菜单 开始 -->
<div class="contextMenu" id="jqueryDtreeMenu" style="display:none;">
  <ul>
    <li id="new"><img src="tree/rightkey_menu_img/folder.png" /><span class="m">新建</span></li>
    <li id="modify"><img src="tree/rightkey_menu_img/disk.png" /><span class="m">修改</span></li>
    <li id="delete"><img src="tree/rightkey_menu_img/cross.png" /><span class="m">删除</span></li>
    <li id="refresh"><img src="tree/rightkey_menu_img/refresh.png" /><span class="m">刷新</span></li>
  </ul>
</div>
<!-- 右键菜单 结束 -->